package concurrency.chapter11;

/**
 * @author honway.liu
 * @date 2019-07-04 20:50
 * @email gm100861@gmail.com
 * @blog http://linuxsogood.org
 */
public class FutureService {

    public <T> Future<T> submit(final FutureTask<T> task) {
        AsyncFuture<T> asyncFuture = new AsyncFuture<>();
        new Thread(() -> {
            T result = task.call();
            asyncFuture.done(result);
        }).start();
        return asyncFuture;
    }
}
